/**
 * 该文件定义了前端常用的一些常量、选项组等等
 */
import _ from 'lodash';
import React from "react";
import { Select } from "antd";

const { Option } = Select;

export const TenantRights = [
  { name: '普通租户', val: '00000000001' },
  { name: '资深租户', val: '00000000009' },
];
export const getTenantRights = (value) => {
  const index = _.findIndex(TenantRights, (o) => o.val === value);
  if (index !== -1) {
    return TenantRights[index].name;
  }
  return value;
}

export const AdminerType = [
  { type: '管理员', val: '00000000001' },
];
export const getAdminerType = (value) => {
  const index = _.findIndex(AdminerType, (o) => o.val === value);
  if (index !== -1) {
    return AdminerType[index].name;
  }
  return value;
}

export const AdminerTenant = [
  { name: '茶百道供应商', val: '00000000001' },
  { name: '书亦集团有限公司', val: '00000000009' }
];

export const getAdminerTenant = (value) => {
  const index = _.findIndex(AdminerTenant, (o) => o.val === value);
  if (index !== -1) {
    return AdminerTenant[index].name;
  }
  return value;
}

// 常用单位数组
export const units = ["L", "ML", "G", "KG"]
// 常用单位 options
export const unitOptions = (
  units.map((ele, index) => {
    return(
      <Option key={index} value={ele}>{ele}</Option>
    )
  })
)

// 常用包装形式数组
export const packTypes = ["袋", "桶", "罐", "包" ]
// 常用包装形式 options
export const packTypeOptions = (
  packTypes.map((ele, index) => {
    return(
      <Option key={index} value={ele}>{ele}</Option>
    )
  })
)

// 常用时间周期数组
export const periods = ["月", "周", "天"]
// 常用时间周期 options
export const periodOptions = (
  periods.map((ele, index) => {
    return(
      <Option key={index} value={ele}>{ele}</Option>
    )
  })
)

// 常用存储方式数组
export const storages = ["密封", "避光", "冷藏", "干燥", "煮沸"]
// 常用时间周期 options
export const storageOptions = (
  storages.map((ele, index) => {
    return(
      <Option key={index} value={ele}>{ele}</Option>
    )
  })
)

